package com.us.usws.common.resourcetree.impl.multiple;

import com.us.usws.common.resourcetree.ResourceTreeRawDataProvider;
import com.us.usws.common.resourcetree.model.CheckBoxResourceTree;

/**
 * @author Wang Jianbo
 */
public class SampleDeptMultipleTreeProvider extends ResourceTreeRawDataProvider<CheckBoxResourceTree> {

	private long rootId;

	public SampleDeptMultipleTreeProvider() {
		this.rootId = 0;
	}

	public SampleDeptMultipleTreeProvider(long rootId) {
		this.rootId = rootId;
	}

	@Override
	public String getSQL() {
		return "select dept_id,parent_id,name from sys_dept where type<>2 start with parent_id =?  connect by prior dept_id = parent_id order siblings by seq_num";
	}

	@Override
	public CheckBoxResourceTree processRawData(Object[] row) {
		long id = ((Number) row[0]).longValue();
		long parentId = Long.parseLong(String.valueOf(row[1]));
		return new CheckBoxResourceTree(id, parentId, (String) row[2]);
	}

	@Override
	public String getKey() {
		return "multipleDeptTreeWithoutCompanies";
	}

	@Override
	public long getRootId() {
		return this.rootId;
	}

	@Override
	public Class<CheckBoxResourceTree> getNodeClass() {
		return CheckBoxResourceTree.class;
	}
}
